/**
 */
package org.mro.grib.model.files.secondEdition.dataRepresentations.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationTemplate550;
import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Representation Template550</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#getReferenceValue <em>Reference Value</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#getBinaryScaleFactor <em>Binary Scale Factor</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#getDecimalScaleFactor <em>Decimal Scale Factor</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#getPackedValueBitsNumber <em>Packed Value Bits Number</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate550Impl#getRealPartOfCoefficient <em>Real Part Of Coefficient</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataRepresentationTemplate550Impl extends EObjectImpl implements DataRepresentationTemplate550 {
	/**
	 * The default value of the '{@link #getReferenceValue() <em>Reference Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferenceValue()
	 * @generated
	 * @ordered
	 */
	protected static final int REFERENCE_VALUE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getReferenceValue() <em>Reference Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferenceValue()
	 * @generated
	 * @ordered
	 */
	protected int referenceValue = REFERENCE_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getBinaryScaleFactor() <em>Binary Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBinaryScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected static final short BINARY_SCALE_FACTOR_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBinaryScaleFactor() <em>Binary Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBinaryScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected short binaryScaleFactor = BINARY_SCALE_FACTOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected static final short DECIMAL_SCALE_FACTOR_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected short decimalScaleFactor = DECIMAL_SCALE_FACTOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getPackedValueBitsNumber() <em>Packed Value Bits Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackedValueBitsNumber()
	 * @generated
	 * @ordered
	 */
	protected static final byte PACKED_VALUE_BITS_NUMBER_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getPackedValueBitsNumber() <em>Packed Value Bits Number</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackedValueBitsNumber()
	 * @generated
	 * @ordered
	 */
	protected byte packedValueBitsNumber = PACKED_VALUE_BITS_NUMBER_EDEFAULT;

	/**
	 * The default value of the '{@link #getRealPartOfCoefficient() <em>Real Part Of Coefficient</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRealPartOfCoefficient()
	 * @generated
	 * @ordered
	 */
	protected static final int REAL_PART_OF_COEFFICIENT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getRealPartOfCoefficient() <em>Real Part Of Coefficient</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRealPartOfCoefficient()
	 * @generated
	 * @ordered
	 */
	protected int realPartOfCoefficient = REAL_PART_OF_COEFFICIENT_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataRepresentationTemplate550Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataRepresentationsPackage.Literals.DATA_REPRESENTATION_TEMPLATE550;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getReferenceValue() {
		return referenceValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReferenceValue(int newReferenceValue) {
		int oldReferenceValue = referenceValue;
		referenceValue = newReferenceValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REFERENCE_VALUE, oldReferenceValue, referenceValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getBinaryScaleFactor() {
		return binaryScaleFactor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBinaryScaleFactor(short newBinaryScaleFactor) {
		short oldBinaryScaleFactor = binaryScaleFactor;
		binaryScaleFactor = newBinaryScaleFactor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__BINARY_SCALE_FACTOR, oldBinaryScaleFactor, binaryScaleFactor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getDecimalScaleFactor() {
		return decimalScaleFactor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDecimalScaleFactor(short newDecimalScaleFactor) {
		short oldDecimalScaleFactor = decimalScaleFactor;
		decimalScaleFactor = newDecimalScaleFactor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__DECIMAL_SCALE_FACTOR, oldDecimalScaleFactor, decimalScaleFactor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getPackedValueBitsNumber() {
		return packedValueBitsNumber;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPackedValueBitsNumber(byte newPackedValueBitsNumber) {
		byte oldPackedValueBitsNumber = packedValueBitsNumber;
		packedValueBitsNumber = newPackedValueBitsNumber;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__PACKED_VALUE_BITS_NUMBER, oldPackedValueBitsNumber, packedValueBitsNumber));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getRealPartOfCoefficient() {
		return realPartOfCoefficient;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRealPartOfCoefficient(int newRealPartOfCoefficient) {
		int oldRealPartOfCoefficient = realPartOfCoefficient;
		realPartOfCoefficient = newRealPartOfCoefficient;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REAL_PART_OF_COEFFICIENT, oldRealPartOfCoefficient, realPartOfCoefficient));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REFERENCE_VALUE:
				return getReferenceValue();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__BINARY_SCALE_FACTOR:
				return getBinaryScaleFactor();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__DECIMAL_SCALE_FACTOR:
				return getDecimalScaleFactor();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__PACKED_VALUE_BITS_NUMBER:
				return getPackedValueBitsNumber();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REAL_PART_OF_COEFFICIENT:
				return getRealPartOfCoefficient();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REFERENCE_VALUE:
				setReferenceValue((Integer)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__BINARY_SCALE_FACTOR:
				setBinaryScaleFactor((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__PACKED_VALUE_BITS_NUMBER:
				setPackedValueBitsNumber((Byte)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REAL_PART_OF_COEFFICIENT:
				setRealPartOfCoefficient((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REFERENCE_VALUE:
				setReferenceValue(REFERENCE_VALUE_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__BINARY_SCALE_FACTOR:
				setBinaryScaleFactor(BINARY_SCALE_FACTOR_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor(DECIMAL_SCALE_FACTOR_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__PACKED_VALUE_BITS_NUMBER:
				setPackedValueBitsNumber(PACKED_VALUE_BITS_NUMBER_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REAL_PART_OF_COEFFICIENT:
				setRealPartOfCoefficient(REAL_PART_OF_COEFFICIENT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REFERENCE_VALUE:
				return referenceValue != REFERENCE_VALUE_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__BINARY_SCALE_FACTOR:
				return binaryScaleFactor != BINARY_SCALE_FACTOR_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__DECIMAL_SCALE_FACTOR:
				return decimalScaleFactor != DECIMAL_SCALE_FACTOR_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__PACKED_VALUE_BITS_NUMBER:
				return packedValueBitsNumber != PACKED_VALUE_BITS_NUMBER_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE550__REAL_PART_OF_COEFFICIENT:
				return realPartOfCoefficient != REAL_PART_OF_COEFFICIENT_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (referenceValue: "); //$NON-NLS-1$
		result.append(referenceValue);
		result.append(", binaryScaleFactor: "); //$NON-NLS-1$
		result.append(binaryScaleFactor);
		result.append(", decimalScaleFactor: "); //$NON-NLS-1$
		result.append(decimalScaleFactor);
		result.append(", packedValueBitsNumber: "); //$NON-NLS-1$
		result.append(packedValueBitsNumber);
		result.append(", realPartOfCoefficient: "); //$NON-NLS-1$
		result.append(realPartOfCoefficient);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.dataRepresentations.IDataRepresentation#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		referenceValue = buffer.getInt();
		binaryScaleFactor = buffer.getShort();
		decimalScaleFactor = buffer.getShort();
		packedValueBitsNumber = buffer.get();
		realPartOfCoefficient = buffer.getInt();
	}
	
} //DataRepresentationTemplate550Impl
